function fu() {
    $.ajax({
        url: '/my/category/list',
        success: function (res) {
            if (res.status === 0) {
                let str = ''
                res.data.forEach(item => {
                    str += ` <tr>
                     <td>${item.name}</td>
                     <td>${item.alias}</td>
                     <td>
                       <button type="button" class="layui-btn layui-btn-xs">编辑</button>
                       <button type="button" class="layui-btn layui-btn-xs layui-btn-danger">删除</button>
                     </td>
                     </tr>`
                });
                $('tbody').html(str)
            }
        }
    })
}
fu()

let addindex
$('.layui-btn-normal').on('click', function () {
    addindex = layer.open({
        type: 1,
        content: $('#tpl-add').html(), //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
        area: ['500px', '300px']
    });
})

$('body').on('submit', '#add-form', function (e) {
    e.preventDefault();
    let data = $(this).serialize()
    $.ajax({
        url: '/my/category/add',
        type: 'POST',
        data: data,
        success: function (res) {
            if (res.status === 0) {
                layer.msg(res.message)
                fu()
                layer.close(addindex)
            }
        }
    })
})

// $('tbody').on('click', '')